home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / Interim Executive Decision / Outline Table Demo / sources / CEditItem.cp < prev    next >
Encoding:
Text File  |  1998-06-21  |  1.3 KB  |  78 lines  |  [TEXT/CWIE]

  1. //============================================================================
  2. // CEditItem.cp            ©1997 Metrowerks Inc. All rights reserved
  3. // Original author: John C. Daub
  4. //============================================================================
  5.  
  6. #include "CEditItem.h"
  7. #include <LInPlaceEditField.h>
  8.  
  9.  
  10. CEditItem::CEditItem()
  11. {
  12.     LString::CopyPStr( "\pfoo", mText );
  13.     mEditField = nil;
  14. }
  15.  
  16. CEditItem::~CEditItem()
  17. {
  18.     // nothing
  19. }
  20.  
  21.  
  22. void
  23. CEditItem::GetDrawContentsSelf(
  24.     const STableCell&        inCell,
  25.     SOutlineDrawContents&    ioDrawContents)
  26. {
  27.  
  28.     switch (inCell.col)
  29.     {
  30.         case 1:
  31.         {
  32.             ioDrawContents.outShowSelection = true;
  33.             ioDrawContents.outTextTraits.style = 0;
  34.             ioDrawContents.outCanDoInPlaceEdit = true;
  35.             
  36.             LString::CopyPStr( mText, ioDrawContents.outTextString);
  37.             
  38.             break;
  39.         }
  40.     }
  41. }
  42.  
  43.  
  44. void
  45. CEditItem::StartInPlaceEdit(
  46.     const STableCell&    inCell)
  47. {
  48.     LEditableOutlineItem::StartInPlaceEdit( inCell );
  49.  
  50.     // we need to listen for the edit field to stop editing
  51.     
  52.     mEditField = GetEditField();
  53.     ThrowIfNil_(mEditField);
  54.     
  55.     mEditField->AddListener(this);
  56.     mEditField->SetValueMessage(100);
  57. }
  58.  
  59. void
  60. CEditItem::ListenToMessage(
  61.     MessageT    inMessage,
  62.     void         *ioParam )
  63. {
  64. #pragma unused(ioParam)
  65.  
  66.     switch ( inMessage )
  67.     {
  68.         case 100:
  69.         {
  70.             mEditField->GetDescriptor( mText );
  71.             if ( mText[0] == 0 ) {
  72.                 mText = "\p-";
  73.             }
  74.             break;
  75.         }
  76.     }
  77. }
  78.